-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhancement: Detect polymorphic associations in generator #3645
base: main
Are you sure you want to change the base?
Conversation
def fields_from_model_tags | ||
tags.each do |name, _| | ||
fields[(remove_last_word_from name).pluralize] = {field: "tags"} | ||
def detect_polymorphic_associations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method detect_polymorphic_associations
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Code Climate has analyzed commit d7adb9a and detected 1 issue on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, @Nevelito!
I have a few questions:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're getting close to merge this @Nevelito
I let some comments about reusing the code we have instead creating a new method for the polymorphic string constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is looking good @Nevelito
Let's just change the message when types are empty and add the types on the test, otherwise is good to merge.
Thank you for this contribution!
I think reduce 3 lines in resource_generator is impossible, we can reduce one here and move first " if " to first line:
Of course if we want to keep the code readable |
@Nevelito, I noticed that the generated types aren't constants. They should be formatted like this: Alternatively, However, my last suggestion mistakenly converted |
I tried to use constantize witch should fix this issue but it returns types like this
|
I know, I don't know a easy way to achieve this, could you do some research on this please? |
I created alias with new inspect function and keep original inspect in function original_inspect, now it works as it should but let me know what you think |
@Nevelito you did that change on the Suggesting this change to all the users is not ideal and monkey patching the Let's try to achieve this output: |
I am not sure if it is possible, I tried to find something but nothing works, only changing inspect gave us wanted result but I see that we can not make like that because of this is in dummy app. I not sure what can we do now. |
… generator to handle inspect
Description
Changes:
Fixes # (issue)
#3536
Checklist: